<?php
/*
Template Name: Home Page
*/
?>
<?php get_header(); ?>
        <div id="container">
            <div id="content">
					
            	<div id="featured-intro">
            		<div id="intro">
            			<?php // featured event loop
            			$featured_event = new WP_Query('showposts=1&category_name=events');
						while ($featured_event->have_posts()) : $featured_event->the_post();
						?>
            			<div id="f-event" class="entry-title">
            				<h2><a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'spartans-speak'), the_title_attribute('echo=0') ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
            			</div>
            			<?php the_content(); ?>
            			<?php endwhile; ?>
            		</div><!-- #intro -->
            		
            		<div class="sliderContainer">
  						<div id="mySlides">
  							<?php
  							$featured = new WP_Query('category_name=featured&posts_per_page=4');
							$post_cache = array();
							if($featured->have_posts()) :
								while($featured->have_posts()) :
									$featured->the_post();
							?>
    						<div class="slide">
      							<div class="slide-thumbnail">
									<?php 
									if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
  										the_post_thumbnail('slider-image');
									} 
									?>
      							</div>
      							<div class="slideContent">
      								<h3><a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'spartans-speak'), the_title_attribute('echo=0') ); ?>" rel="bookmark"><?php the_title(); ?></a></h3>
        							<?php the_excerpt(); ?>
      							</div>
    						</div>
    					<?php
								endwhile;
						endif;
						?>
  						</div>
  						<div id="myController">
    						<span class="jFlowControl"></span>
    						<span class="jFlowControl"></span>
    						<span class="jFlowControl"></span>
    						<span class="jFlowControl"></span>
  						</div>
  						<div class="jFlowPrev"></div>
						<div class="jFlowNext"></div>
					</div><!-- .sliderContainer -->

            		<div id="events" class="group">
            			<?php // events loop
            			$events = new WP_Query('showposts=3&category_name=events');
						while ($events->have_posts()) : $events->the_post();
						?>
						<article id="post-<?php the_ID(); ?>">
							<header>
								<div class="entry-title">
									<h3><a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'spartans-speak'), the_title_attribute('echo=0') ); ?>" rel="bookmark"><?php the_title(); ?></a></h3>
								</div>
							</header>
							<div class="entry-content">
								<?php the_excerpt(); ?>
							</div>
						</article>
						<?php endwhile; ?>
						
						<div id="more-btn">
							<p>
								<?php
    							// Get the ID of a given category
    							$category_id = get_cat_ID( 'events' );

    							// Get the URL of this category
    							$category_link = get_category_link( $category_id );
								?>

								<!-- Print a link to this category -->
								<a href="<?php echo esc_url( $category_link ); ?>" title="Events">more</a>
							</p>
						</div><!-- #more-btn -->
            		</div><!-- #events -->
            	</div><!-- #featured-intro -->
            	
            	<div id="featured-content" class="group">
            		<div id="f-title" class="entry-title">
            			<h1>Featured Articles</h1>
            		</div>
            		
            		<div id="articles">
            			<?php // featured articles loop
            			$featured = new WP_Query('showposts=2&category_name=featured');
						while ($featured->have_posts()) : $featured->the_post();
						?>
						<article id="<?php the_ID(); ?>" class="group">
							<header>
								<div class="entry-title">
									<h3><a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'spartans-speak'), the_title_attribute('echo=0') ); ?>" rel="bookmark"><?php the_title(); ?></a></h3>
								</div>
							</header>
							<div class="entry-content">
								<?php the_excerpt(); ?>
							</div>
							<div class="read-btn">
								<a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'spartans-speak'), the_title_attribute('echo=0') ); ?>" rel="bookmark">Read More</a>
							</div>
						</article>
						<?php endwhile; ?>
            		</div><!-- #articles -->
            		
            		<aside id="discussion">
            			<?php if ( is_sidebar_active('discussion_widget_area') ) : ?>
							<div id="discussion-content" class="widget-area">
								<ul class="xoxo">
								<?php dynamic_sidebar('discussion_widget_area'); ?>
								</ul>
							</div><!-- #discussion-content .widget-area -->
						<?php endif; ?>
            		</aside><!-- #discussion -->
            	</div><!-- #featured-content -->
            </div><!-- #content -->
        </div><!-- #container -->
<?php get_footer(); ?>
